/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.zcm.modules.xgb.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.zcm.common.config.Global;
import com.zcm.common.persistence.Page;
import com.zcm.common.web.BaseController;
import com.zcm.common.utils.StringUtils;
import com.zcm.modules.xgb.entity.XgbQuoteChange;
import com.zcm.modules.xgb.service.XgbQuoteChangeService;

/**
 * XgbQuoteChangeController
 * @author www
 * @version 2018-10-07
 */
@Controller
@RequestMapping(value = "${adminPath}/xgb/xgbQuoteChange")
public class XgbQuoteChangeController extends BaseController {

	@Autowired
	private XgbQuoteChangeService xgbQuoteChangeService;
	
	@ModelAttribute
	public XgbQuoteChange get(@RequestParam(required=false) String id) {
		XgbQuoteChange entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = xgbQuoteChangeService.get(id);
		}
		if (entity == null){
			entity = new XgbQuoteChange();
		}
		return entity;
	}
	
	@RequiresPermissions("xgb:xgbQuoteChange:view")
	@RequestMapping(value = {"list", ""})
	public String list(XgbQuoteChange xgbQuoteChange, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<XgbQuoteChange> page = xgbQuoteChangeService.findPage(new Page<XgbQuoteChange>(request, response), xgbQuoteChange); 
		model.addAttribute("page", page);
		return "modules/xgb/xgbQuoteChangeList";
	}

	@RequiresPermissions("xgb:xgbQuoteChange:view")
	@RequestMapping(value = "form")
	public String form(XgbQuoteChange xgbQuoteChange, Model model) {
		model.addAttribute("xgbQuoteChange", xgbQuoteChange);
		return "modules/xgb/xgbQuoteChangeForm";
	}

	@RequiresPermissions("xgb:xgbQuoteChange:edit")
	@RequestMapping(value = "save")
	public String save(XgbQuoteChange xgbQuoteChange, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, xgbQuoteChange)){
			return form(xgbQuoteChange, model);
		}
		xgbQuoteChangeService.save(xgbQuoteChange);
		addMessage(redirectAttributes, "保存XgbQuoteChange成功");
		return "redirect:"+Global.getAdminPath()+"/xgb/xgbQuoteChange/?repage";
	}
	
	@RequiresPermissions("xgb:xgbQuoteChange:edit")
	@RequestMapping(value = "delete")
	public String delete(XgbQuoteChange xgbQuoteChange, RedirectAttributes redirectAttributes) {
		xgbQuoteChangeService.delete(xgbQuoteChange);
		addMessage(redirectAttributes, "删除XgbQuoteChange成功");
		return "redirect:"+Global.getAdminPath()+"/xgb/xgbQuoteChange/?repage";
	}

}